<%@ page language="java" pageEncoding="UTF-8"%>
<!--分页查询共用的页面-->
<%@ include file="/common/common.jsp"%>

</head>


<script type="text/javascript" charset="utf-8">

////////////////////////////////////////////////////////////////解决$.browser被移除的问题
jQuery.browser = {};
(function () {
    jQuery.browser.msie = false;
    jQuery.browser.version = 0;
    if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
        jQuery.browser.msie = true;
        jQuery.browser.version = RegExp.$1;
    }
})();


///////////////////////////////////////////////////////////////变量
var veh_m = {};//定义对象
veh_m.debug = true;
veh_m.slctUrl = globalConfig.webPath + "/basicSlctAction/basicSelectData.action";


////////////////////////////////////////////////////////////////初始化控件
//接口，初始化控件
veh_m.initDivs = function(){
	this.initIndustryDiv();
	this.initTermTypeDiv();
	this.initDepDiv();
	this.initRunStatusDiv();
	this.initSortDiv();
}

//初始化运行类型数据
veh_m.initIndustryDiv = function(){
	let that = this;
	let param = {
		queryId:"basicData.selectIndustryType",
	};
	Utility.getAjaxData(that.slctUrl,JSON.stringify(param),function(data){
		// that.outDebug("接收到运营类型基本信息" , data);
		if(data.success){
			// let list = [];
			// list.push({text:'请选择',value:''});
			let html = '';
			html += '<option value="">请选择</option>';
			if(data.data.length > 0){
				$.each(data.data,function(n,item){
					// list.push({text:item.name,value:item.id});
					html += '<option value="' + item.id + '">' + item.name + '</option>';
				});
			}
			$("#veh_m_industry").html(html);
			// $("#veh_m_industry").combobox({
			// 	textField: "text",
			// 	valueField: "value",
			// 	editable: false,
			// 	data: list
			// });

		}else{
			DataUtil.showErrorMsg(data.message);
		}
	});
}

//初始化终端类型控件
veh_m.initTermTypeDiv = function(){
	let that = this;
	let param = {
		parent : 'TerminalType',
		queryId : "basicData.selectBasicData",
	};
	Utility.getAjaxData(that.slctUrl,JSON.stringify(param),function(data){
		// that.outDebug("接收到终端类型基本信息：" , data);
		if(data.success){
			let html = '';
			html += '<option value="">请选择</option>';
			if(data.data.length > 0){
				$.each(data.data,function(n,item){
					if(item.code != 'TerminalType'){
						html += '<option value="' + item.code + '">' + item.name + '</option>';
					}
				});
			}
			$("#veh_m_termType").html(html);
		}else{
			DataUtil.showErrorMsg(data.message);
		}
	});
}

//初始化车组数据
veh_m.initDepDiv = function(){
	//创建下拉部门树
	Utility.createOrganzationTree("depId");
}

//初始化运行状态控件
veh_m.initRunStatusDiv = function(){
	$("#runStatus").lookup({ category: "runStatus" });

	$("#runStatus").change(function () {
		var txt = $("#runStatus").find("option:selected").text();
		$("#runStatusText").val(txt);
	});
}

//初始化排序控件
veh_m.initSortDiv = function(){
	$("#sortText").change(function () {
		var txt = $("#sortText").find("option:selected").text();
		$("#runStatusText").val(txt);
	});
}




////////////////////////////////////////////////////////////////获取数据
//查询按钮点击事件
veh_m.loadQueryDatas = function(){
	// Utility.loadGridWithParams();
	var queryForm = $("#queryForm").ajaxForm();
	var formData = queryForm.formToArray();
	var queryParams = {};
	for (var m in formData) {
		if (formData[m].value != "" && formData[m].value != undefined) {
			queryParams[formData[m].name] = formData[m].value;
		}
	}
	$("#queryGrid").datagrid("load", queryParams);
}


	

////////////////////////////////////////////////////////////////控件事件
//弹窗选择部门
veh_m.doSelectDep = function()
{
	InfoWindow.selectDep();
}
function onDepSelected(depId,depName)
{
	$("#depId").combotree("setValue", depId);
}

veh_m.reset = function(){
	// veh_m.outDebug("开始重置");
	$("#queryForm")[0].reset();
}

////////////////////////////////////////////////////////////////表格数据格式化
//删除表格的某一行，删除后，会自动刷新表格
veh_m.getDeleteActionColumn = function(value, rowData, rowIndex){
	var entityId = rowData.vehicleId;
	var html = "<img style='cursor: pointer;' src='<%=imgPath%>/cross.gif' onclick=\"Utility.deleteEntity('<%=ApplicationPath%>/vehicle/delete.action','" + entityId + "');\"/>";
	return html;
}
//编辑列
veh_m.getEditActionColumn = function(value, rowData, rowIndex){
	var entityId = rowData.vehicleId;
	var html = "<a href=\"javascript:InfoWindow.viewVehicle('" + entityId + "');\">" + " 编辑</a>";
	return html;
}
//查看驾驶员信息列
veh_m.getDriverActionColumn = function(value, rowData, rowIndex){
	var driverId = rowData.driverId;
	var driverName = rowData.driverName;
	if (driverId) {
		var html = "<a href=\"javascript:InfoWindow.viewDriverInfo('" + driverId + "');\">" + driverName + "</a>";
		return html;
	}else{
		return "";
	}
}
////////////////////////////////////////////////////////////////公共方法
//输出调试信息
veh_m.outDebug = function(msg,data){
	if(this.debug == true){
		DataUtil.outDebug(msg,data);
	}
}


////////////////////////////////////////////////////////////////加载后执行
$(document).ready(function () {
	veh_m.initDivs();
	// Utility.loadGridWithParams();
}); 


</script>

		
<body style="background-color:rgb(251,251,251);height:100%;" class="base_ver_flexStartDiv_css">
<div id="toolbar" style="width:100%;">
	<form id="queryForm" action="<%=ApplicationPath%>/vehicle/paginate.action" method="POST">
		<input type="hidden" name="queryId" value="vehicle.selectVehicles" />
		<input type="hidden" name="fileName" value="车辆列表" />
		<input type="hidden" id="runStatusText" name="runStatusText" value="" />
		<input type="hidden" id="sortText" name="sortText" value="按车牌号排序" />
		<!--上层按钮栏-->
		<div style="width:80%;margin-left: 15px;margin-top:5px;">
			<a id="btnNew" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="InfoWindow.viewVehicle(0);" >添加</a>
			&nbsp;&nbsp;
			<a id="btnReset" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-clear'" onclick="javascript:veh_m.reset();">重置</a>
			&nbsp;&nbsp;
			<a id="btnExport" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-excel'" 
			onclick="Utility.excelExport('<%=ApplicationPath%>/export.action');">导出</a>
		</div>
		<!--下层查询工具栏-->
		<hr>
		<div style="width:100%;height:80px;" class="base_hori_flexStartDiv_css">
			<!--左侧条件样式-->
			<div style="height:100%;margin-left: 15px;margin-top:7px;" class="base_ver_Around_leftDiv_css">
				<div>
					组织<select id="depId" name="depId" style="width:130px;"></select>
					<a id="btnSelectVehicle" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="veh_m.doSelectDep();"></a>
					车牌号码<input type="text" name="plateNo" size="20" id="veh_m_plateNo" style="width:140px;">
					通讯SIM卡号<input type="text" name="simNo" size="20" style="width:110px;">
					真实SIM卡号<input type="text" name="seqNo" size="20" style="width:110px;">
					营运类型：<select id="veh_m_industry" name="industry" style="width:100px;"></select>
					车辆运维状态：<select id="runStatus" name="runStatus" style="width:100px;"></select>
				</div>
				<div style="margin-top:5px;">
					终端类型<select id="veh_m_termType" name="termType" style="width:100px;"></select>
					终端 ID<input type="text" name="termNo" style="width:110px;">
					服务开始时间
					<input type="text" name="install_startDate" class="easyui-datetimebox" style="width:147px;">
					<span>-</span>
					<input type="text" name="install_endDate" class="easyui-datetimebox" style="width:147px;">
				</div>
				<div style="margin-top:5px;">
					服务到期时间
					<input type="text" name="end_startDate" class="easyui-datetimebox" style="width:120px;">
					<span>-</span>
					<input type="text" name="end_endDate" class="easyui-datetimebox" style="width:120px;">
					驾驶员<input type="text" name="driverName" size="20" style="width:100px;">
					排序
					<select id="sortBy" name="sortBy" style="width:110px;">
						<option value="plateNo">按车牌号排序</option>
						<option value="installDate">按安装时间排序</option>
						<option value="endDate">按到期时间排序</option>
					</select>
				</div>
			</div>
			<!--右侧按钮-->
			<div style="margin-left:20px;" class="base_hori_flexCenterDiv_css">
				<a id="btnQuery" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="veh_m.loadQueryDatas();">查询</a>
			</div>
		</div>
		
	</form>

</div>
<div style="flex:1;width:100%;">
	<table id="queryGrid" class="easyui-datagrid" title="" style="width:100%;" data-options="pagination:true,pageSize:15,singleSelect:true,rownumbers:true,striped:true,fitColumns: false,
								pageList: [15, 20, 50, 100, 150, 200],fit:true,
								url:'<%=ApplicationPath%>/vehicle/paginate.action',method:'get'">
		<thead>
			<tr>
				<th data-options="field:'2',formatter:veh_m.getDeleteActionColumn">删除</th>
				<th data-options="field:'1',formatter:veh_m.getEditActionColumn">编辑</th>
				<th data-options="field:'depName1'" width="80">所属组织</th>
				<th data-options="field:'plateNo'" width="80">车牌号码</th>
				<th data-options="field:'plateColor'" width="60">车牌颜色</th>
				<th data-options="field:'simNo'" width="110">通讯SIM卡号</th>
				<th data-options="field:'seqNo'" width="110">真实SIM卡号</th>
				<th data-options="field:'runStatus'" width="70">车辆运维状态</th>
				<th data-options="field:'installDate'" width="130">服务开始时间</th>
				<th data-options="field:'endDate'" width="130">服务结束时间</th>
				<th data-options="field:'industryTypeName'" width="100">营运类型</th>
				<th data-options="field:'terminalType'" width="90">终端类型</th>
				<th data-options="field:'termNo'" width="115">终端ID</th>
				<th data-options="field:'driverName',formatter:veh_m.getDriverActionColumn" width="60">主驾驶</th>
				<th data-options="field:'vehicleType'" width="80">车辆类型</th>
				<th data-options="field:'regionName'" width="80">车籍地</th>
				<th data-options="field:'processedUser'" width="100">最后操作人</th>
			</tr>
		</thead>
	</table>

</div>

</body>

